import axios from 'axios'

const api = axios.create({
  baseURL: '/api/demo',
  timeout: 5000
})

// 电商相关API
export const movieApi = {
  getList: () => api.get('/getallitems?typeIndex=2'),
  getSingle: (id) => api.get(`/getsingle?id=${id}&typeIndex=2`),
  create: (data) => api.post('/additem', { ...data, typeIndex: 2 })
}

// 评论相关API
export const commentApi = {
  getList: (movieId) => 
    api.get(`/getallitems?typeIndex=5&articleid=${movieId}&replyType=电商`),
  create: (data) => api.post('/additem', { ...data, typeIndex: 5 })
}

// 用户相关API
export const userApi = {
  register: (data) => api.post('/reg', data),
  login: (data) => api.post('/login', data)
}

export default api